<template>
    <div>
      <el-form ref="form" :model="form" label-width="80px">
        <el-form-item label="活动名称">
          <el-input v-model="form.name"></el-input>
        </el-form-item>
        <el-form-item label="活动区域">
          <span class="label-span" style="margin-left: 30px">活动地址:</span>
          <el-select v-model="form.region" placeholder="请选择活动区域">
            <el-option label="区域一" value="shanghai"></el-option>
            <el-option label="区域二" value="beijing"></el-option>
          </el-select>
          <span class="label-span" style="margin-left: 30px">产品类型:</span>
          <el-select v-model="productTypeList" multiple collapse-tags placeholder="请选择产品类型" class="select-item" @change="testData">
            <el-option v-for="item1 in productTypes"
                       :key="item1.value"
                       :label="item1.name"
                       :value="item1.value">
                <span>{{item1.name}}</span>
                <div class="el-pot-right">
                  <el-option v-for="item2 in item1.children"
                             :key="item2.value"
                             :label="item2.name"
                             :value="item2.value">
                    <span>{{item2.name}}</span>
                  </el-option>
                </div>
            </el-option>
          </el-select>

        </el-form-item>
        <el-form-item label="即时配送">
          <el-col :span="11">
            <my-select :tree-data="treeData" v-model="treeDataList"></my-select>
          </el-col>
          <el-col :span="11">
            <el-button @click="getSelectData">取值</el-button>
          </el-col>
        </el-form-item>
        <el-form-item label="活动时间">
          <el-col :span="11">

          </el-col>
          <el-col class="line" :span="2">-</el-col>
          <el-col :span="11">

          </el-col>
        </el-form-item>
        <el-form-item label="即时配送">
          <el-switch v-model="form.delivery"></el-switch>
        </el-form-item>
        <el-form-item label="活动性质">
          <el-checkbox-group v-model="form.type">
            <el-checkbox label="美食/餐厅线上活动" name="type"></el-checkbox>
            <el-checkbox label="地推活动" name="type"></el-checkbox>
            <el-checkbox label="线下主题活动" name="type"></el-checkbox>
            <el-checkbox label="单纯品牌曝光" name="type"></el-checkbox>
          </el-checkbox-group>
        </el-form-item>
        <el-form-item label="特殊资源">
          <el-radio-group v-model="form.resource">
            <el-radio label="线上品牌商赞助"></el-radio>
            <el-radio label="线下场地免费"></el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="活动形式">
          <el-input type="textarea" v-model="form.desc"></el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="onSubmit">立即创建</el-button>
          <el-button>取消</el-button>
        </el-form-item>
      </el-form>
    </div>
</template>
<script type="text/ecmascript-6">
  import MySelect from '../sub/MySelect.vue'

    export default {
        components: {
            MySelect
        },
        data() {
            return {
                form: {
                    name: '',
                    region: '',
                    date1: '',
                    date2: '',
                    delivery: false,
                    type: [],
                    resource: '',
                    desc: ''
                },
                productTypeList:[],
                productTypes:[
                    {
                        name:"熟食类",
                        value:"cooked",
                        children:[
                            {
                                name:"炸鸡腿",
                                value:"drumstick"
                            },
                            {
                                name:"辣条",
                                value:"strips"
                            },
                            {
                                name:"小鱼干",
                                value:"fillet"
                            },
                            {
                                name:"老干妈",
                                value:"old"
                            }
                        ]
                    },
                    {
                        name:"炒货类",
                        value:"mast",
                        children:[
                            {
                                name:"杏仁",
                                value:"almond"
                            },
                            {
                                name:"腰果",
                                value:"cashew"
                            },
                            {
                                name:"夏威夷果",
                                value:"macadamia"
                            },
                            {
                                name:"开心果",
                                value:"pistachio"
                            },
                            {
                                name:"核桃",
                                value:"walnut"
                            }
                        ]
                    },
                    {
                        name:"水果类",
                        value:"fruit",
                        children:[
                            {
                                name:"苹果",
                                value:"apple"
                            },
                            {
                                name:"香蕉",
                                value:"banana"
                            },
                            {
                                name:"菠萝",
                                value:"pineapple"
                            },
                            {
                                name:"草莓",
                                value:"strawberry"
                            }
                        ]
                    }
                ],

                treeDataList:[],
                treeData:[
                    {
                        label:"熟食类",
                        value:"cooked",
                        children:[
                            {
                                label:"炸鸡腿",
                                value:"drumstick"
                            },
                            {
                                label:"辣条",
                                value:"strips"
                            },
                            {
                                label:"小鱼干",
                                value:"fillet"
                            },
                            {
                                label:"老干妈",
                                value:"old"
                            },
                            {
                                label:"烤面包",
                                value:"bao"
                            }
                        ]
                    },
                    {
                        label:"炒货类",
                        value:"mast",
                        children:[
                            {
                                label:"杏仁",
                                value:"almond"
                            },
                            {
                                label:"腰果",
                                value:"cashew"
                            },
                            {
                                label:"夏威夷果",
                                value:"macadamia"
                            },
                            {
                                label:"开心果",
                                value:"pistachio"
                            },
                            {
                                label:"核桃",
                                value:"walnut"
                            }
                        ]
                    },
                    {
                        label:"水果类",
                        value:"fruit",
                        children:[
                            {
                                label:"苹果",
                                value:"apple"
                            },
                            {
                                label:"香蕉",
                                value:"banana"
                            },
                            {
                                label:"菠萝",
                                value:"pineapple"
                            },
                            {
                                label:"草莓",
                                value:"strawberry"
                            }
                        ]
                    }
                ]
            }
        },
        methods: {
            onSubmit() {
                console.log('submit!');
            },
            getSelectData(){
                console.log('--------------------');
                console.log(this.treeDataList);
            },
            testData(){
                console.log(this.productTypeList);
            }
        }
    }
</script>
<style>
  .el-pot-right{
    position: absolute;
    top:0;
    right: -105%;
    width: 100%;
    display: none;
    background-color: white;
    border: 1px solid #E4E7ED;
    border-radius: 4px;
    padding: 5px 0;
  }
  .is-multiple .el-scrollbar{
    overflow: initial;
  }
  .is-multiple .el-scrollbar__wrap{
    overflow: initial;
    margin-right:0 !important;
    margin-bottom: 0 !important;
  }
  .is-multiple .el-select-dropdown__item{
    overflow: initial;
  }
  .is-multiple .el-select-dropdown__item>.el-pot-right:hover{
    display: inline-block;
  }
  .is-multiple .el-select-dropdown__item.hover>.el-pot-right{
    display: inline-block;
  }
</style>
